<template>
    <div class="mainDiv">
        <div class="rowHead">
            <el-button type="warning" icon="el-icon-h-edit" @click="edit" v-qx="permission.edit">修改</el-button>
        </div>
        <el-table :data="cate" height="100%">
            <el-table-column prop="type" label="客户类型"></el-table-column>
            <el-table-column prop="A" label="A类"></el-table-column>
            <el-table-column prop="B" label="B类"></el-table-column>
            <el-table-column prop="C" label="C类"></el-table-column>
            <el-table-column prop="D" label="D类"></el-table-column>
            <el-table-column prop="E" label="E类"></el-table-column>
        </el-table>
        <el-alert class="mt" title="说明：会员分类标准为半年一统计，请设置会员各个分类等级的标准。" type="success" :closable="false">
        </el-alert>
    </div>
</template>
<script>
import C from '#/src/common/common.js'
export default {
    name: 'guestCategoryList',
    data() {
        return {
            zong: {},
            cate: [],
            id: 0,
            permission: {
                edit: 'fenlei_edit',
            }
        }
    },
    mounted() {
        this.getInfo()
    },
    methods: {
        edit: async function() {
            let res = await C.openBrowserWindow('/guestcategoryEdit', this.zong, {
                transparent: true,
                frame: false,
                width: 600,
                height: 460,
                useSpa: true,
                spaModel: 'organization'
            })
            if (res) {
                C.success(res.data)
                this.getInfo()
            }
        },
        getInfo: async function() {
            let res = await C.ajax('/organization/category/getguestcategory', {}, 'post')
            if (res) {
                this.zong = res
                let a = {},
                    b = {}
                for (let i in res) {
                    if (i.indexOf('_arrive') > 0) {
                        a[i.split('_')[0]] = res[i] + ' 次'
                        a.type = '到店次数'
                        a.ct = 1
                    } else if (i.indexOf('_money') > 0) {
                        b[i.split('_')[0]] = res[i] + ' 元'
                        b.type = '消费金额'
                        b.ct = 2
                    } else {
                        this.id = res[i]
                    }
                }
                this.cate = [a, b]
            }
        }
    }
}
</script>